package alik.notes.client.event;

import alik.notes.shared.data.Note;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

public class Events {

	public static class NoteAddEvent extends GwtEvent<NoteAddHandler> {

		private static final Type<NoteAddHandler> TYPE = new Type<NoteAddHandler>();

		public static Type<NoteAddHandler> getType() {
			return TYPE;
		}

		private Note note;

		public NoteAddEvent(Note note) {
			this.note = note;
		}


		@Override
		public final Type<NoteAddHandler> getAssociatedType() {
			return TYPE;
		}

		public Note getNote() {
			return note;
		}

		@Override
		protected void dispatch(NoteAddHandler handler) {
			handler.addNote(note);
		}

	}

	public interface NoteAddHandler extends EventHandler {
		void addNote(Note note);
	}



	public static class NotesChangeEvent extends GwtEvent<NotesChangeHandler> {

		private static final Type<NotesChangeHandler> TYPE = new Type<NotesChangeHandler>();

		public static Type<NotesChangeHandler> getType() {
			return TYPE;
		}
		
		@Override
		public final Type<NotesChangeHandler> getAssociatedType() {
			return TYPE;
		}

		@Override
		protected void dispatch(NotesChangeHandler handler) {
			handler.notesChanged();
		}

	}

	public interface NotesChangeHandler extends EventHandler {
		void notesChanged();
	}
}
